package com.autosalon.ui;

import com.autosalon.ui.automobil.Automobil;
import com.autosalon.ui.banka.Banka;
import com.autosalon.ui.customer.Customer;
import com.autosalon.ui.doplnek.Doplnek;
import com.autosalon.ui.objednavka.Objednavka;
import com.autosalon.ui.spravaPojisteni.SpravaPojisteni;
import com.autosalon.ui.spravaPujcek.SpravaPujcek;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Panel;

public class ContentSwitcher extends Panel implements Button.ClickListener {

	private final char switchTo;
	private final MainGuiWindow mainWindow;
	public static char HOME_PANEL = 'h';
	public static char AUTOMOBIL_PANEL = 'a';
	public static char REGISTRATION_PANEL = 'r';
	public static char OBJEDNAVKA_PANEL = 'o';
        public static char DOPLNKY_PANEL = 'd';
        public static char BANKY_PANEL = 'b';
        public static char PUJCKY_PANEL = 'p';
        public static char POJISTENI_PANEL = 'j';

	public ContentSwitcher(MainGuiWindow mainWindow, char switchTo) {
		this.switchTo = switchTo;
		this.mainWindow = mainWindow;
	}

	public void setContent(char content) {
        switch (content) {
            case 'h':{
        	removeAllComponents();
        	addComponent(getMainWindow().getContentLabel());
        	break;
            }
            case 'j':{
            	removeAllComponents();
            	addComponent(new SpravaPojisteni(this));
            	break;
                }
            case 'a': {
                removeAllComponents();
                addComponent(new Automobil(this));
                break;
            }
            case 'b': {
                removeAllComponents();
                addComponent(new Banka(this));
                break;
            }
            case 'p': {
                removeAllComponents();
                addComponent(new SpravaPujcek(this));
                break;
            }
            case 'r': {
                removeAllComponents();
                addComponent(new Customer(this));
                break;
            }
            case 'o': {
                removeAllComponents();
                addComponent(new Objednavka(this));
                break;
            }
            case 'd': {
                removeAllComponents();
                addComponent(new Doplnek(this));
                break;
            }
        }
    }

	@Override
	public void buttonClick(ClickEvent event) {
		removeAllComponents();

		this.mainWindow.getSwitcher().setContent(switchTo);

	}

	public MainGuiWindow getMainWindow() {
		return mainWindow;
	}
}
